Add ostree_commit_get_parent() to get parent from variant
authorStef Walter <stefw@redhat.com>
Wed, 14 Aug 2013 09:46:50 +0000 (11:46 +0200)
committerStef Walter <stefw@redhat.com>
Thu, 15 Aug 2013 04:52:53 +0000 (06:52 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=705973

src/libostree/ostree-core.c
src/libostree/ostree-core.h
src/libostree/ostree-repo-traverse.c

index 92311418283dd6cdbd2eab145e5e58e01f953f2f..f746b337c8d57e127ca416fa822b01f22638b779 100644 (file)
@@ -1643,3 +1643,13 @@ ostree_validate_structureof_dirmeta (GVariant      *dirmeta,
  out:
   return ret;
 }
+
+gchar *
+ostree_commit_get_parent (GVariant  *commit_variant)
+{
+  gs_unref_variant GVariant *bytes = NULL;
+  bytes = g_variant_get_child_value (commit_variant, 1);
+  if (g_variant_n_children (bytes) == 0)
+    return NULL;
+  return ostree_checksum_from_bytes_v (bytes);
+}
index a28b0ca8a8f5c2271ded0c4448246e258929b632..b2d24e64dfc789d74758b63efa4b8ddf9a69ebca 100644 (file)
@@ -319,5 +319,6 @@ gboolean ostree_validate_structureof_dirtree (GVariant      *index,
 gboolean ostree_validate_structureof_dirmeta (GVariant      *index,
                                               GError       **error);
 
+gchar *  ostree_commit_get_parent            (GVariant  *commit_variant);
 
 G_END_DECLS
index 996033e967cf16f8596abd023262a0dffbc34cbb..d15fc6ca9aa480d592c40ca3509a3746db2bef48 100644 (file)
@@ -211,12 +211,10 @@ ostree_repo_traverse_commit (OstreeRepo      *repo,
 
       if (maxdepth == -1 || maxdepth > 0)
         {
-          g_variant_get_child (commit, 1, "@ay", &parent_csum_bytes);
-          
-          if (g_variant_n_children (parent_csum_bytes) > 0)
+          g_free (tmp_checksum);
+          tmp_checksum = ostree_commit_get_parent (commit);
+          if (tmp_checksum)
             {
-              g_free (tmp_checksum);
-              tmp_checksum = ostree_checksum_from_bytes_v (parent_csum_bytes);
               commit_checksum = tmp_checksum;
               if (maxdepth > 0)
                 maxdepth -= 1;
@@ -231,4 +229,3 @@ ostree_repo_traverse_commit (OstreeRepo      *repo,
  out:
   return ret;
 }
-